package com.byedu.course.controller;

import com.byedu.course.UserQuestionService;
import com.byedu.domain.course.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/userquestion")
public class UserQuestionController {

    @Autowired
    private UserQuestionService userQuestionService;

    @ResponseBody
    @RequestMapping(value = "/list/{userId}", method = {RequestMethod.GET})
    public List<UserQuestionVO> getUserQuestionsByUserId(@PathVariable String userId) {
        return userQuestionService.listUserQuestionsByUserId(userId);
    }

    /**
     * @param userId
     * @param questionId
     * @param subOptions
     * @return
     * @description 录入用户答题记录
     * @author chenxigui
     * @date 2017-04-29
     */
    @ResponseBody
    @RequestMapping(value = "/manage", method = {RequestMethod.POST})
    public boolean getQuestionsByLibraryId(@RequestParam(value = "userId", required = true) String userId,
                                           @RequestParam(value = "questionId", required = true) int questionId,
                                           @RequestParam(value = "subOptions", required = true) String subOptions) {

        userQuestionService.manage(userId, questionId, subOptions);
        return true;
    }

}
